package com.blog.controller;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.blog.entity.User;
import com.blog.service.UserService;
import com.blog.service.VerificationService;
import com.blog.service.Impl.UserServiceImpl;
import com.blog.service.Impl.VerificationServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;

@WebServlet("/UserLoginServlet.do")
public class UserLoginServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserService userservice = new UserServiceImpl();
		VerificationService vs = new VerificationServiceImpl();
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		response.setContentType("application/json;charset=utf-8");
		new ObjectMapper().writeValue(response.getWriter(), userservice.selectUserByName(username, password));
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
